package sudroid.security;

public class Base64
{
  private static char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray();
  private static byte[] codes = new byte[256];

  static
  {
    int i = 0;
    if (i >= 256)
    {
      i = 65;
      label28: if (i <= 90)
        break label83;
      i = 97;
      label37: if (i <= 122)
        break label104;
      i = 48;
    }
    while (true)
    {
      if (i > 57)
      {
        codes[43] = 62;
        codes[47] = 63;
        return;
        codes[i] = -1;
        i += 1;
        break;
        label83: byte[] arrayOfByte1 = codes;
        int j = (byte)(i - 65);
        arrayOfByte1[i] = j;
        i += 1;
        break label28;
        label104: byte[] arrayOfByte2 = codes;
        int k = (byte)(i + 26 - 97);
        arrayOfByte2[i] = k;
        i += 1;
        break label37;
      }
      byte[] arrayOfByte3 = codes;
      int m = (byte)(i + 52 - 48);
      arrayOfByte3[i] = m;
      i += 1;
    }
  }

  public static byte[] decode(char[] paramArrayOfChar)
  {
    int i = (paramArrayOfChar.length + 3) / 4 * 3;
    if (paramArrayOfChar.length > 0)
    {
      int j = paramArrayOfChar.length - 1;
      if (paramArrayOfChar[j] == '=')
        i += -1;
    }
    if (paramArrayOfChar.length > 1)
    {
      int k = paramArrayOfChar.length - 2;
      if (paramArrayOfChar[k] == '=')
        i += -1;
    }
    byte[] arrayOfByte1 = new byte[i];
    int m = 0;
    int n = 0;
    int i1 = 0;
    int i2 = 0;
    while (true)
    {
      int i3 = paramArrayOfChar.length;
      if (i2 >= i3)
      {
        int i4 = arrayOfByte1.length;
        if (i1 == i4)
          break;
        throw new RuntimeException("miscalculated data length!");
      }
      byte[] arrayOfByte2 = codes;
      int i5 = paramArrayOfChar[i2] & 0xFF;
      int i6 = arrayOfByte2[i5];
      if (i6 >= 0)
      {
        int i7 = n << 6;
        m += 6;
        n = i7 | i6;
        if (m >= 8)
        {
          int i8 = m + -8;
          int i9 = i1 + 1;
          int i10 = (byte)(n >> i8 & 0xFF);
          arrayOfByte1[i1] = i10;
          int i11 = i9;
        }
      }
      i2 += 1;
    }
    return arrayOfByte1;
  }

  public static char[] encode(byte[] paramArrayOfByte)
  {
    char[] arrayOfChar1 = new char[(paramArrayOfByte.length + 2) / 3 * 4];
    int i = 0;
    int j = 0;
    int k = paramArrayOfByte.length;
    if (i >= k)
      return arrayOfChar1;
    int m = 0;
    int n = 0;
    int i1 = (paramArrayOfByte[i] & 0xFF) << 8;
    int i2 = i + 1;
    int i3 = paramArrayOfByte.length;
    if (i2 < i3)
    {
      int i4 = i + 1;
      int i5 = paramArrayOfByte[i4] & 0xFF;
      i1 |= i5;
      n = 1;
    }
    i1 <<= 8;
    int i6 = i + 2;
    int i7 = paramArrayOfByte.length;
    if (i6 < i7)
    {
      int i8 = i + 2;
      int i9 = paramArrayOfByte[i8] & 0xFF;
      i1 |= i9;
      m = 1;
    }
    int i10 = j + 3;
    char[] arrayOfChar2 = alphabet;
    if (m != 0)
    {
      i11 = i1 & 0x3F;
      label156: int i12 = arrayOfChar2[i11];
      arrayOfChar1[i10] = i12;
      i1 >>= 6;
      i10 = j + 2;
      arrayOfChar2 = alphabet;
      if (n == 0)
        break label303;
    }
    label303: for (int i11 = i1 & 0x3F; ; i11 = 64)
    {
      int i13 = arrayOfChar2[i11];
      arrayOfChar1[i10] = i13;
      int i14 = i1 >> 6;
      int i15 = j + 1;
      char[] arrayOfChar3 = alphabet;
      int i16 = i14 & 0x3F;
      int i17 = arrayOfChar3[i16];
      arrayOfChar1[i15] = i17;
      int i18 = i14 >> 6;
      int i19 = j + 0;
      char[] arrayOfChar4 = alphabet;
      int i20 = i18 & 0x3F;
      int i21 = arrayOfChar4[i20];
      arrayOfChar1[i19] = i21;
      i += 3;
      j += 4;
      break;
      i11 = 64;
      break label156;
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.security.Base64
 * JD-Core Version:    0.6.0
 */